/**
  ******************************************************************************
  * @file    operation_interface.h
  * @brief   运营平台接口处理
  ******************************************************************************
  */

#ifndef __OPERATION_INTERFACE_H
#define __OPERATION_INTERFACE_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "operation_protocol_data_def.h"

/** 运营平台服务类型 */
typedef enum {
    OPS_ACTIVE_SERVICE_START_CHARGING_APP    = 0x34,   /* APP启动充电 */
    OPS_ACTIVE_SERVICE_STOP_CHARGING_APP     = 0x36,   /* APP停止充电 */
    OPS_ACTIVE_SERVICE_CARD_SYN              = 0x44,   /* 离线卡数据同步 */
    OPS_ACTIVE_SERVICE_CARD_CLEAR            = 0x46,   /* 离线卡数据清除 */
    OPS_ACTIVE_SERVICE_CARD_QUERY            = 0x48,   /* 离线卡数据查询 */
    OPS_ACTICE_SERVICE_FEE_STRATEGY          = 0x58,   /* 计费策略 */
    OPS_ACTIVE_SERVICE_TIME_SYN              = 0x56,   /* 时间同步 */
    OPS_ACTIVE_SERVICE_REBOOT                = 0x92,   /* 重启 */
    OPS_ACTIVE_SERVICE_START_UPDATE          = 0x94,   /* 启动远程升级 */

    OPS_PASSIVE_SERVICE_SIGN_IN              = 0x02,   /* 登录签到（充电桩接入认证） */
    OPS_PASSIVE_SERVICE_HEARTBEAT            = 0x04,   /* 心跳 */
    OPS_PASSIVE_SERVICE_FEE_CHECK            = 0x06,   /* 计费策略 */
    OPS_PASSIVE_SERVICE_FEE_STRATEGY         = 0x0A,   /* 计费策略 */
    OPS_PASSIVE_SERVICE_CARD_AUTH            = 0x32,   /* 卡鉴权结果 */
    OPS_PASSIVE_SERVICE_BILL                 = 0x40,   /* 账单 */

    OPS_SERVICE_MAX_SIZE                     = 0xFF,
} ops_service_type_t;

/* 服务回调注册 */
#define OPS_RegisterCallback(service, cb) ops_register_for_##service(cb)

/* 服务回调声明 */
#define OPS_DECLARE_SERVICE_CALLBACK(service, cb) int32_t ops_register_for_##service(cb)

/* 服务回调定义 */
#define OPS_DEFINE_SEVICE_CALLBACK(service, cb)                                              \
    int32_t ops_register_for_##service(cb)                                                   \
    {                                                                                        \
        if (service < 0)                                                                     \
        {                                                                                    \
            return (-1);                                                                     \
        }                                                                                    \
        g_ops_service_map[service].callback = (void *)callback;                              \
        return (0);                                                                          \
    }

void *ops_service_callback(int32_t service);

/* 服务回调函数声明 */
OPS_DECLARE_SERVICE_CALLBACK(OPS_ACTIVE_SERVICE_START_CHARGING_APP,    \
                             int32_t (*cb)(ops_active_service_start_charging_app_t *request, ops_active_service_feedback_start_charging_app_t *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_ACTIVE_SERVICE_STOP_CHARGING_APP,     \
                             int32_t (*cb)(ops_active_service_stop_charging_app_t *request, ops_active_service_feedback_stop_charging_app_t *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_ACTIVE_SERVICE_CARD_SYN,              \
                             int32_t (*cb)(ops_active_service_card_syn_t *request, ops_active_service_feedback_card_syn_t *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_ACTIVE_SERVICE_CARD_CLEAR,            \
                             int32_t (*cb)(ops_active_service_card_clear_t *request, ops_active_service_feedback_card_clear_t *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_ACTIVE_SERVICE_CARD_QUERY,            \
                             int32_t (*cb)(ops_active_service_card_query_t *request, ops_active_service_feedback_card_query_t *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_ACTICE_SERVICE_FEE_STRATEGY,              \
                             int32_t (*cb)(ops_passive_service_fee_strategy_t *request, ops_active_service_feedback_fee_strategy_t *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_ACTIVE_SERVICE_TIME_SYN,              \
                             int32_t (*cb)(ops_active_service_time_syn_t *request, ops_active_service_feedback_time_syn_t *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_ACTIVE_SERVICE_REBOOT,                \
                             int32_t (*cb)(ops_active_service_reboot_t *request, ops_active_service_feedback_reboot_t *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_ACTIVE_SERVICE_START_UPDATE,          \
                             int32_t (*cb)(ops_active_service_start_update_t *request, ops_active_service_feedback_start_update_t *feedback));

OPS_DECLARE_SERVICE_CALLBACK(OPS_PASSIVE_SERVICE_SIGN_IN,              \
                             int32_t (*cb)(ops_passive_service_sign_in_t *request, void *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_PASSIVE_SERVICE_HEARTBEAT,            \
                             int32_t (*cb)(ops_passive_service_heartbeat_t *request, void *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_PASSIVE_SERVICE_FEE_CHECK,         \
                             int32_t (*cb)(ops_passive_service_fee_mode_check_t *request, void *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_PASSIVE_SERVICE_FEE_STRATEGY,         \
                             int32_t (*cb)(ops_passive_service_fee_strategy_t *request, void *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_PASSIVE_SERVICE_CARD_AUTH,            \
                             int32_t (*cb)(ops_passive_service_card_authorize_t *request, void *feedback));
OPS_DECLARE_SERVICE_CALLBACK(OPS_PASSIVE_SERVICE_BILL,                 \
                             int32_t (*cb)(ops_passive_service_bill_t *request, void *feedback));

#ifdef __cplusplus
}
#endif

#endif /* __OPERATION_INTERFACE_H */
